package com.bleeth.fx.view.demo2;

import com.bleeth.fx.component.MIcon;
import com.bleeth.fx.helper.ControlsHelper;
import com.bleeth.fx.helper.StyleHelper;
import com.bleeth.fx.layout.FormBuilder;
import com.bleeth.fx.layout.GirdCell;
import com.bleeth.fx.meta.IForm;
import com.bleeth.fx.meta.View;
import com.bleeth.fx.meta.ViewRouter;
import javafx.beans.property.Property;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;

/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@View(value = "left")
public class LeftView implements IForm {

    private VBox LeftForm;
    private Label label_icon_1;
    private Label label_icon_2;


    @Override
    public Region make(Property... properties) {

        label_icon_1 = ControlsHelper.createLabel("Icon", "", "");
        label_icon_2 = ControlsHelper.createLabel("Icon", "", "");

        LeftForm = FormBuilder.form(null, null)
                .addEmptyRow(40D)
                .addRow(GirdCell.createCell(15D, Pos.CENTER), GirdCell.createCell(20D, Pos.CENTER_LEFT), GirdCell.createCell(15D, Pos.CENTER),
                        GirdCell.createCell(1, Pos.CENTER_LEFT)
                )
                .addCell(1, MIcon.builder().icon("icon-sunny").size(20).color("#717171").build().make())
                .addCell(3, label_icon_1)
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(15D, Pos.CENTER), GirdCell.createCell(20D, Pos.CENTER_LEFT), GirdCell.createCell(15D, Pos.CENTER),
                        GirdCell.createCell(1, Pos.CENTER_LEFT)
                )
                .addCell(1, MIcon.builder().icon("icon-sunny").size(20).color("#717171").build().make())
                .addCell(3, label_icon_2)
                .endRow(false)
                .build();
        css();
        return LeftForm;
    }

    @Override
    public void css() {
        StyleHelper.ft(label_icon_1).fill("#6e6e6e").size(14).make();
        StyleHelper.ft(label_icon_2).fill("#6e6e6e").size(14).make();

    }


    public EventHandler iconClick(String icon) {
        Label title = new Label(icon);
        Label desc = new Label(icon + "......" + "click....");
        StyleHelper.ft(title).size(18).make();
        StyleHelper.ft(desc).size(14).make();

        return new EventHandler() {
            @Override
            public void handle(Event event) {
                ViewRouter.change("label_title", title);
                ViewRouter.change("label_desc", desc);
                ViewRouter.change("content_box", "login");
            }
        };
    }


}
